#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;


void getLongestSequence(int input[], int size)
{
    vector<int> dp(size+1, 1);
    vector<int> pre(size+1, -1);
    int maxVector = 0;
    int maxIndex;
    for (int i = 0; i < size; i++) {
        for (int j = 0; j < i; j++) {
            if (input[j] < input[i]) {
                if(dp[i] < dp[j]+1) {
                    dp[i] = dp[j]+1;
                    pre[i] = j;
                    if (dp[i] > maxVector) {
                        maxVector = dp[i];
                        maxIndex = i;
                    }
                }
            }
        }
    }
    cout << maxVector << endl;
    int cur = maxIndex;
    while (cur != -1) {
        cout << input[cur] << " " ;
        cur = pre[cur];
    }
   cout << endl; 
   for (int i = 0; i < size; i++) 
       cout << input[i] << " " << pre[i] << endl;
}

int main(int argc, char **argv)
{
    int input[] = {1,3,4,6,7,4,3,6,7,1,9,5,7,6,8,9,12,14,11,15};

    getLongestSequence(input, sizeof(input)/sizeof(int));
    cout << "-----------------Test 1--------------------" << endl;


    cout << "-----------------Test 2--------------------" << endl;


    cout << "-----------------Test 3--------------------" << endl;


    cout << "-----------------Test 4--------------------" << endl;


    cout << "-----------------Test 5--------------------" << endl;



}
